package com.tbit.uqbike.webmanager.util;

import com.tbit.uqbike.object.value.FinaStat;
import org.springframework.web.servlet.support.RequestContext;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: chen
 * @Description: 财务导出工具类
 * @Date: 创建于 14:59 2020/6/30
 */
public class FinaExportUtil {

    /**
     * 组装数据
     *
     * @param machines
     * @param context
     * @return
     */
    public static List<String[]> getExportContent(List<FinaStat> machines, RequestContext context) {
        List<String[]> result = new ArrayList<String[]>();
        /*标题*/
        String[] title = {"区域运营商",
                "骑行总金额(元)", "骑行总订单数",
                "充值总金额(元)", "充值订单数",
                "骑行卡总金额(元)", "骑行卡订单数",
                "免押卡总金额(元)", "免押卡订单数",
                "会员卡总金额(元)", "会员卡订单数",
                "骑行订单退款总金额(元)", "骑行订单退款总数",
                "欠款补交订单总金额", "欠款补交订单数",
                "欠款订单总金额", "欠款订单数",
                "设备数量", "新增用户数量"};
        result.add(title);
        /**金额转化为元*/
        for (FinaStat finaStat : machines) {
            if (null != finaStat) {
                String[] content = {finaStat.getName(),
                        String.valueOf(finaStat.getRideMoney() * 1.0 / 100), String.valueOf(finaStat.getRideCount()),
                        String.valueOf(finaStat.getRechargeMoney() * 1.0 / 100), String.valueOf(finaStat.getRechargeNum()),
                        String.valueOf(finaStat.getRideCardMoney() * 1.0 / 100), String.valueOf(finaStat.getRideCardCount()),
                        String.valueOf(finaStat.getMemMoney() * 1.0 / 100), String.valueOf(finaStat.getMemCount()),
                        String.valueOf(finaStat.getVipMoney() == null ? 0 : finaStat.getVipMoney() * 1.0 / 100), String.valueOf(finaStat.getVipCount() == null ? 0 : finaStat.getVipCount()),
                        finaStat.getTotalMoneyRefund() > 0 ? "-" + (finaStat.getTotalMoneyRefund() * 1.0 / 100) : "" + finaStat.getTotalMoneyRefund(), String.valueOf(finaStat.getTotalNumberOfRefunds()),
                        String.valueOf(finaStat.getDeptPay() * 1.0 / 100), String.valueOf(finaStat.getDeptPayNum()),
                        String.valueOf(finaStat.getDept() * 1.0 / 100), String.valueOf(finaStat.getDeptNum()),
                        String.valueOf(finaStat.getMachineNum()), String.valueOf(finaStat.getNewUser())};
                result.add(content);
            }
        }
        return result;
    }
}
